/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facades;

import entities.Candidate;
import entities.CandidateSearchInterest;
import entities.Search;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Alvaro
 */
@Stateless
public class CandidateSearchInterestFacade extends AbstractFacade<CandidateSearchInterest> {
    @PersistenceContext(unitName = "ProyectoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CandidateSearchInterestFacade() {
        super(CandidateSearchInterest.class);
    }
    public boolean exitsCandidateSearchInterest(Candidate candidate, Search search){
        List<String>res= new ArrayList<String>();
        Query namedQuery=em.createNamedQuery("CandidateSearchInterest.findByCandidateAndSearch");
        namedQuery.setParameter("candidate", candidate);
        namedQuery.setParameter("search", search);
        List<CandidateSearchInterest>objects =namedQuery.getResultList();
        return !objects.isEmpty();
    }
    
}
